//
//  ZDDVisitorTableViewController.swift
//  小蜗牛_新浪微博
//
//  Created by 周冬冬 on 16/6/25.
//  Copyright © 2016年 我的mac. All rights reserved.
//

import UIKit

class ZDDVisitorTableViewController: UITableViewController {
    
    let islogin :Bool = ZDDUserAccountTools.sharedTools.islogin
    
    var visitorView : ZDDVisitorView?
    override func loadView() {
        if islogin {
            //用户登录
            super.loadView()
        }else{
            //用户没有登录
            setVisitorView()
       
            
        }
    }
    //  MARK: - 设置访客视图
    
    
    private func setVisitorView(){
    setupNavC()
        visitorView = ZDDVisitorView()
        //设置颜色
//        visitorView.backgroundColor = RandomColor()
        
        visitorView?.closure = {
        [weak self] in
        self?.loginClick()
        
        }
        
        view = visitorView
    
    }
     //  MARK: - 设置导航栏
    private func setupNavC(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
    
    }
  @objc private func loginClick(){
    
    //弹出登录控制器
    let oauthVC = ZDDOAuthViewController()
    
    let navC = UINavigationController(rootViewController: oauthVC)
    navigationController?.navigationBarHidden = true
    presentViewController(navC, animated: true, completion: nil)
    
    
    
    }
    override func viewDidLoad() {
       
   
        
        
        
    }
    

}
